﻿@{
    Layout = null;
    var rootmenu = ViewBag.ROOTMENU as List<StrObjDict>;
    var submenu = ViewBag.SUBMENU as List<StrObjDict>;
    rootmenu = rootmenu ?? new List<StrObjDict>();
    submenu = submenu ?? new List<StrObjDict>();

}
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width" />
    <title>护理知识在线学习 WSS</title>
    <link href="@Href("~/Content/bootstrap-3.1.1-dist/css/bootstrap.min.css")" rel="stylesheet" />
    <link href="@Href("~/Content/normalize.css")" rel="stylesheet" />
    <link href="@Href("~/Content/font-awesome-4.1.0/css/font-awesome.min.css")" rel="stylesheet" />

    <style type="text/css">
        *
        {
            margin: 0;
            padding: 0;
        }

        .topmenu
        {
            position: fixed;
            left: 0;
            top: 0;
            width: 210px;
            background-color: white;
            z-index: 1;
        }

            .topmenu .head
            {
                height: 50px;
                text-align: center;
                color: white;
                font: normal normal 16px/50px microsoft yahei;
                background-color: black;
            }

        .toptab
        {
            position: fixed;
            left: 210px;
            top: 0;
            height: 50px;
            width: 100%;
            background-color: black;
            z-index: -1;
        }

        .top_icon
        {
            position: fixed;
            top: 15px;
            right: 10px;
            font: normal normal 14px/16px Microsoft Yahei;
        }

            .top_icon a
            {
                color: white;
                text-decoration: none;
                font: normal normal 16px/16px microsoft yahei;
            }

        #lockscreen
        {
            background-color: lightblue;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 234;
        }

            #lockscreen #lockscreen_main
            {
                position: relative;
                top: 30%;
                left: 35%;
                width: 400px;
                height: 300px;
                text-align: center;
            }
    </style>
</head>
<body>
    <div style="width: 100%">
        <div class="topmenu" id="topmenu">
            <div class="head">简惠科技</div>
            <ul id="nav" style="overflow: hidden; width: 210px; margin: 0; padding: 0; height: 100%;">
                @foreach (var root in rootmenu)
                {
                    <li data-menuid="@root["CD_ID"]" data-bgc="@root["CD_BKCOLOR"]" data-url="@root["URL"]">
                        <a href="#@root["URL"]">
                            <i class="@root["CD_ICON"]"></i>
                            <span>@root["CD_MC"]</span>
                        </a>

                        @{
                    var realsubmenu = submenu.Where(t => Utils.GetString(t["CD_PID"]) == Utils.GetString(root["CD_ID"])).ToList();
                    if (realsubmenu.Count > 0)
                    {
                            <ul>
                                @foreach (var sub in realsubmenu)
                                {
                                    <li data-menuid="@sub["CD_ID"]" data-url="@sub["URL"]">
                                        <a href="#@sub["URL"]">
                                            <i class="fa fa-caret-right"></i>
                                            <span>@sub["CD_MC"]</span>
                                        </a>
                                    </li> 
                                }
                            </ul>
                    }
                        }

                    </li>
                }
            </ul>
        </div>

        <div class="toptab">
            <ul class="nav nav-tabs" id="toptab" style="margin-top: 9px;">
                <li class="active">
                    <a href="#home" data-toggle="tab">欢迎</a>
                </li>
            </ul>



        </div>
        <div class="tab-content" id="toptab_content">
            <div class="tab-pane active" id="home">
                <iframe frameborder="0"  style="position: fixed; left: 210px; top: 50px; border: 0" @*id="mainframe"*@ src="/adm/home"></iframe>
            </div>
        </div>

    </div>

    <div class="top_icon">
        <div class="dropdown">
            <a data-toggle="dropdown" href="#">
                <img id="headimg"  height="30" style="cursor: pointer;" width="30" src="@Url.Content("~/Content/images/head/" + ViewBag.USERPIC)" alt="@(ViewBag.UserName)" class="img-circle">
                <span>
                    @ViewBag.UserName (@ViewBag.UserNo)
                </span>
            </a>

            <ul class="dropdown-menu" role="menu">
                <li role="presentation">
                    <a href="#" role="menuitem">
                        <span class="glyphicon glyphicon-bell"></span>
                        消息
                    </a>

                </li>
                <li role="presentation">
                    <a href="javascript:void(0)" role="menuitem" tabindex="-1" onclick="personalsetting()">
                        <span class="glyphicon glyphicon-cog"></span>
                        设置
                    </a>
                </li>
                <li role="presentation">
                    <a href="javascript:void(0)" role="menuitem" tabindex="-1" onclick="handLock()">
                        <span class="glyphicon glyphicon-lock"></span>
                        锁屏
                    </a>
                </li>
                <li role="presentation" class="divider"></li>
                <li role="presentation">
                    <a href="/account/logout" role="menuitem" tabindex="-1">
                        <span class="glyphicon glyphicon-off"></span>
                        登出
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.11.0.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/bootstrap-3.1.1-dist/js/bootstrap.min.js")"></script>
    <script type="text/javascript">

        var topwin = {
            userid: '@ViewBag.UserId',
            username: '@ViewBag.UserName'
        }
        var toptab = {
            addTab: function (title, id, src) {
                if (toptab.exsistTab(id)) {
                    $("#toptab a[href='#" + id + "']").tab('show');
                    return;
                }
                $("#toptab").append('<li><a href="#' + id + '" data-toggle="tab">' + title + '<i class="close" onclick="toptab.removeTab(\'' + id + '\')"> &times;</i></a></li>');
                var $frame = $("#home").find("iframe").clone();
                $frame.attr("src", src);
                $("#toptab_content").append('<div class="tab-pane active" id="' + id + '">' + $frame.get(0).outerHTML + '</div>');
                $('#toptab a:last').width($('#toptab a:last').width() + 15).tab('show');
            },
            exsistTab: function (id) {
                var ret = false;
                $("#toptab a").each(function (idx, obj) {
                    ret = $(this).attr("href") == ("#" + id);
                    if (ret) {
                        return false;//break
                    }
                });
                return ret;
            },
            removeTab: function (id) {
                //获取当前li的前一个li
                var prevLi = $("#toptab a[href='#" + id + "']").parent("li").prev();
                var prevLi_aHref = prevLi.find("a").attr("href");

                $("#toptab a[href='#" + id + "']").parent("li").remove();
                $("#toptab_content div[id='" + id + "']").remove();

                prevLi.addClass("active").siblings(".active").removeClass("active");
                $("#toptab_content div[id='" + prevLi_aHref.substring(1) + "']").addClass("active").siblings(".active").removeClass("active");
            }
        };

        function personalsetting() {
            toptab.addTab("个人设置", "peson12alse12tting", "/adm/personalsetting");
        }

        var interval_num;
        function handLock() {
            $.post("/login/handlock", { userid: '@ViewBag.UserId' }, function (data) {
                if (data.flag) {
                    if (data.msg == "lock") {
                        $("#lockscreen").slideToggle();
                        $("#lockpwd").val('');
                        clearInterval(interval_num);
                    } else {
                        top.location.replace("/login/login");
                    }
                }
            });
        }

        //离开10分钟即自动锁屏(auto=1)手动(auto=0)
        function autoLock() {
            interval_num = setInterval(function () {
                $.post("/login/autolock", { userid: '@ViewBag.UserId' }, function (data) {
                    if (data.flag) {
                        if (data.msg == "lock") {
                            $("#lockscreen").slideToggle();
                            $("#lockpwd").val('');
                            clearInterval(interval_num);
                        } else {
                            top.location.replace("/login/login");
                        }
                    }
                });
            }, 5 * 60 * 1000);
            }

            $(function () {

                $("#lockpwd").bind("keydown", function (evt) {
                    var e = evt || widows.event;
                    if (e.keyCode == "13") {
                        var pwd = $("#lockpwd").val();
                        if (pwd.length) {
                            $.post("/login/unlockscreen", { userpwd: pwd }, function (data) {
                                if (data.flag) {
                                    $("#lockscreen").slideToggle();
                                    autoLock();
                                } else {
                                    $('#lockpwd').select().popover({
                                        content: data.msg,
                                        placement: "top"
                                    }).popover('show');
                                    setTimeout(function () {
                                        $('#lockpwd').popover('destroy');
                                    }, 3000);
                                }
                            });
                        }
                    }
                });

                function init() {
                    $("#nav > li").click(function () {
                        var $li = $(this);
                        if ($li.hasClass("active")) {
                            $li.removeClass("active");
                        } else {
                            $li.addClass("active").siblings(".active").find("ul").slideToggle().end().removeClass("active");
                        }

                        if ($li.find("ul").size()) {
                            $li.find("ul").slideToggle();
                        } else {
                            onLeafmenuClick($li);
                        }

                    }).mouseover(function () {
                        var $li = $(this);
                        var bgc = $li.data("bgc");
                        $li.find("i:not(.fa-caret-right)").addClass(bgc);
                    }).mouseleave(function () {
                        var $li = $(this);
                        var bgc = $li.data("bgc");
                        $li.find("i:not(.fa-caret-right)").removeClass(bgc);
                    });

                    $("#nav > li > ul > li").click(function (e) {
                        if (e && e.stopPropagation) {
                            e.stopPropagation();
                        } else {
                            window.event.cancelBubble = true;
                        }

                        onLeafmenuClick($(this));

                    });

                    var winheight = $(window).height(), winwidth = $(window).width();

                    $("iframe").height(winheight - 50);
                    $("iframe").width(winwidth - 210);

                    autoLock();
                }

                function onLeafmenuClick($li) {
                    $li.addClass("active").siblings(".active").removeClass("active");

                    var text = $li.find("span").text();
                    var menuid = $li.data("menuid");
                    var menuurl = $li.data("url");
                    if (menuurl && menuurl != "//") {
                        toptab.addTab(text, menuid, menuurl);
                    }
                }

                init();

            });


    </script>


    <div id="lockscreen" style="display: none;">
        <div id="lockscreen_main">
            <img height="120"  width="120" src="@Url.Content("~/Content/images/head/" + ViewBag.USERPIC)" class="img-circle">
            <input type="password" class="form-control" style="margin-top: 20px;" id="lockpwd" placeholder="密码">
            <div class="alert alert-success" id="unlockscreen_txt">
                <p>系统出于帐号安全考虑，在长时间内未操作将会自动锁屏</p>
                <p><em>请输入您的密码后回车解锁</em></p>
            </div>
        </div>
    </div>
</body>
</html>
